/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.hellodoctor.slayer.model.impl;

import com.hellodoctor.slayer.model.Appointment;

import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import java.util.Date;

/**
 * The cache model class for representing Appointment in entity cache.
 *
 * @author Shahbaj
 * @see Appointment
 * @generated
 */
public class AppointmentCacheModel implements CacheModel<Appointment>,
	Externalizable {
	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{appointmentId=");
		sb.append(appointmentId);
		sb.append(", doctorId=");
		sb.append(doctorId);
		sb.append(", patientId=");
		sb.append(patientId);
		sb.append(", appointmentDate=");
		sb.append(appointmentDate);
		sb.append(", appointmentTime=");
		sb.append(appointmentTime);
		sb.append(", status=");
		sb.append(status);
		sb.append(", createDate=");
		sb.append(createDate);
		sb.append(", modifiedDate=");
		sb.append(modifiedDate);
		sb.append("}");

		return sb.toString();
	}

	@Override
	public Appointment toEntityModel() {
		AppointmentImpl appointmentImpl = new AppointmentImpl();

		appointmentImpl.setAppointmentId(appointmentId);
		appointmentImpl.setDoctorId(doctorId);
		appointmentImpl.setPatientId(patientId);

		if (appointmentDate == Long.MIN_VALUE) {
			appointmentImpl.setAppointmentDate(null);
		}
		else {
			appointmentImpl.setAppointmentDate(new Date(appointmentDate));
		}

		appointmentImpl.setAppointmentTime(appointmentTime);
		appointmentImpl.setStatus(status);

		if (createDate == Long.MIN_VALUE) {
			appointmentImpl.setCreateDate(null);
		}
		else {
			appointmentImpl.setCreateDate(new Date(createDate));
		}

		if (modifiedDate == Long.MIN_VALUE) {
			appointmentImpl.setModifiedDate(null);
		}
		else {
			appointmentImpl.setModifiedDate(new Date(modifiedDate));
		}

		appointmentImpl.resetOriginalValues();

		return appointmentImpl;
	}

	@Override
	public void readExternal(ObjectInput objectInput) throws IOException {
		appointmentId = objectInput.readLong();
		doctorId = objectInput.readLong();
		patientId = objectInput.readLong();
		appointmentDate = objectInput.readLong();
		appointmentTime = objectInput.readInt();
		status = objectInput.readInt();
		createDate = objectInput.readLong();
		modifiedDate = objectInput.readLong();
	}

	@Override
	public void writeExternal(ObjectOutput objectOutput)
		throws IOException {
		objectOutput.writeLong(appointmentId);
		objectOutput.writeLong(doctorId);
		objectOutput.writeLong(patientId);
		objectOutput.writeLong(appointmentDate);
		objectOutput.writeInt(appointmentTime);
		objectOutput.writeInt(status);
		objectOutput.writeLong(createDate);
		objectOutput.writeLong(modifiedDate);
	}

	public long appointmentId;
	public long doctorId;
	public long patientId;
	public long appointmentDate;
	public int appointmentTime;
	public int status;
	public long createDate;
	public long modifiedDate;
}